<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>ES6数值的扩展 | LH</title><meta name="keywords" content="ES6"><meta name="author" content="lihao,1767359165@qq.com"><meta name="copyright" content="lihao"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="1.二进制和八进制的表示方法ES6提供了二进制和八进制数值的新的方法，分别用前缀0b（或者0B）和0o（或者00）表示。 2.Number.isFinite(),Number.isNaN()ES6在Number对象上，新提供了Number.isFinite()和Number.isNaN()两个方法。Number.isFinite()用来检查一个数值是否为有限的（finite），即不是Infinit">
<meta property="og:type" content="article">
<meta property="og:title" content="ES6数值的扩展">
<meta property="og:url" content="https://lh521.top/2021/03/09/es6-shu-zhi-de-kuo-zhan/index.html">
<meta property="og:site_name" content="LH">
<meta property="og:description" content="1.二进制和八进制的表示方法ES6提供了二进制和八进制数值的新的方法，分别用前缀0b（或者0B）和0o（或者00）表示。 2.Number.isFinite(),Number.isNaN()ES6在Number对象上，新提供了Number.isFinite()和Number.isNaN()两个方法。Number.isFinite()用来检查一个数值是否为有限的（finite），即不是Infinit">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/03/12/FwCNIhKedQUOlrj.png">
<meta property="article:published_time" content="2021-03-09T02:44:54.000Z">
<meta property="article:modified_time" content="2021-03-09T03:36:52.834Z">
<meta property="article:author" content="lihao">
<meta property="article:tag" content="ES6">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/03/12/FwCNIhKedQUOlrj.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://lh521.top/2021/03/09/es6-shu-zhi-de-kuo-zhan/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-03-09 11:36:52'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><meta name="generator" content="Hexo 5.3.0"><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="iron-container iron-circle"><div class="iron-box1 iron-circle iron-center"></div><div class="iron-box2 iron-circle iron-center"></div><div class="iron-box3 iron-circle iron-center"></div><div class="iron-box4 iron-circle iron-center"></div><div class="iron-box5 iron-circle iron-center"></div><div class="iron-box6 iron-circle"><div class="iron-coil" style="--i: 0"></div><div class="iron-coil" style="--i: 1"></div><div class="iron-coil" style="--i: 2"></div><div class="iron-coil" style="--i: 3"></div><div class="iron-coil" style="--i: 4"></div><div class="iron-coil" style="--i: 5"></div><div class="iron-coil" style="--i: 6"></div><div class="iron-coil" style="--i: 7"></div></div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="/img/touxiang.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">11</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">6</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/bb/"><i class="fa-fw fas fa-music"></i><span> 点点滴滴</span></a></li><li><a class="site-page" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page" href="/xingkong/"><i class="fa-fw fa fa-heartbeat"></i><span> 星空物语</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">LH</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-heartbeat"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/bb/"><i class="fa-fw fas fa-music"></i><span> 点点滴滴</span></a></li><li><a class="site-page" href="/Gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></li><li><a class="site-page" href="/xingkong/"><i class="fa-fw fa fa-heartbeat"></i><span> 星空物语</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">ES6数值的扩展</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-03-09T02:44:54.000Z" title="发表于 2021-03-09 10:44:54">2021-03-09</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-03-09T03:36:52.834Z" title="更新于 2021-03-09 11:36:52">2021-03-09</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/ES6/">ES6</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="1-二进制和八进制的表示方法"><a href="#1-二进制和八进制的表示方法" class="headerlink" title="1.二进制和八进制的表示方法"></a>1.二进制和八进制的表示方法</h1><p>ES6提供了二进制和八进制数值的新的方法，分别用前缀0b（或者0B）和0o（或者00）表示。</p>
<h1 id="2-Number-isFinite-Number-isNaN"><a href="#2-Number-isFinite-Number-isNaN" class="headerlink" title="2.Number.isFinite(),Number.isNaN()"></a>2.Number.isFinite(),Number.isNaN()</h1><p>ES6在Number对象上，新提供了Number.isFinite()和Number.isNaN()两个方法。<br>Number.isFinite()用来检查一个数值是否为有限的（finite），即不是Infinity。</p>
<h1 id="3-Number-parseInt-Number-parseFloat"><a href="#3-Number-parseInt-Number-parseFloat" class="headerlink" title="3.Number.parseInt(),Number.parseFloat()"></a>3.Number.parseInt(),Number.parseFloat()</h1><p>ES6将全局方法parseInt()和parseFloat()，一直到Number对象上面，行为保持不变。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// ES5的写法</span></span><br><span class="line"><span class="built_in">parseInt</span>(<span class="string">&#x27;12.34&#x27;</span>) <span class="comment">// 12</span></span><br><span class="line"><span class="built_in">parseFloat</span>(<span class="string">&#x27;123.45#&#x27;</span>) <span class="comment">// 123.45</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// ES6的写法</span></span><br><span class="line"><span class="built_in">Number</span>.parseInt(<span class="string">&#x27;12.34&#x27;</span>) <span class="comment">// 12</span></span><br><span class="line"><span class="built_in">Number</span>.parseFloat(<span class="string">&#x27;123.45#&#x27;</span>) <span class="comment">// 123.45</span></span><br></pre></td></tr></table></figure>
<p>这样的做法的目的，是逐步减少全局性方法，使得语言逐步模块化。</p>
<h1 id="4-Number-isInteger"><a href="#4-Number-isInteger" class="headerlink" title="4.Number.isInteger()"></a>4.Number.isInteger()</h1><p>Number.isInteger()用来判断一个数值是否为整数。</p>
<p>。<br>。<br>。</p>
<h1 id="7-Math对象的扩展"><a href="#7-Math对象的扩展" class="headerlink" title="7.Math对象的扩展"></a>7.Math对象的扩展</h1><p>ES6在Math对象上新增了17个与数学相关的方法。所有的这些方法都是静态方法，只能在Math对象上调用。</p>
<h2 id="7-1-Math-trunc"><a href="#7-1-Math-trunc" class="headerlink" title="7.1 Math.trunc()"></a>7.1 Math.trunc()</h2><p>Math.trunc方法用于去除一个数的小树部分，返回整数部分。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">Math</span>.trunc(<span class="number">4.1</span>) <span class="comment">// 4</span></span><br><span class="line"><span class="built_in">Math</span>.trunc(<span class="number">4.9</span>) <span class="comment">// 4</span></span><br><span class="line"><span class="built_in">Math</span>.trunc(-<span class="number">4.1</span>) <span class="comment">// -4</span></span><br><span class="line"><span class="built_in">Math</span>.trunc(-<span class="number">4.9</span>) <span class="comment">// -4</span></span><br><span class="line"><span class="built_in">Math</span>.trunc(-<span class="number">0.1234</span>) <span class="comment">// -0</span></span><br></pre></td></tr></table></figure>
<p>对于非数值，Math.trunc内部使用Number方法将其先转数值。<br>对于空值和无法截取整数的值。返回NaN。</p>
<h2 id="7-2-Math-sign"><a href="#7-2-Math-sign" class="headerlink" title="7.2 Math.sign()"></a>7.2 Math.sign()</h2><p>Math.sign方法用来判断一个数到底是正数，负数，还是零。对于非数值，会将其转换为数值。<br>它会返回五种值。<br>参数为正数，返回+1；<br>。。为负数，返回-1；<br>。。为0，     返回0；<br>。。为-0，   返回-0；<br>其他值，      返回NaN；</p>
<h2 id="7-3-Math-cbrt"><a href="#7-3-Math-cbrt" class="headerlink" title="7.3 Math.cbrt()"></a>7.3 Math.cbrt()</h2><p>Math.cbrt()方法用于计算一个数的立方根。</p>
<h2 id="7-4-Math-clz32"><a href="#7-4-Math-clz32" class="headerlink" title="7.4 Math.clz32()"></a>7.4 Math.clz32()</h2><p>方法将参数转化为32位无符号正数的形式，然后返回这个32位值里面有多少个前导0；</p>
<h2 id="7-5-Math-imul"><a href="#7-5-Math-imul" class="headerlink" title="7.5 Math.imul()"></a>7.5 Math.imul()</h2><p>方法返回两个数以32位带符号整数形式相乘的结果，返回的也是一个32位带符号的整数。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">Math</span>.imul(<span class="number">2</span>, <span class="number">4</span>)   <span class="comment">// 8</span></span><br><span class="line"><span class="built_in">Math</span>.imul(-<span class="number">1</span>, <span class="number">8</span>)  <span class="comment">// -8</span></span><br><span class="line"><span class="built_in">Math</span>.imul(-<span class="number">2</span>, -<span class="number">2</span>) <span class="comment">// 4</span></span><br></pre></td></tr></table></figure>
<h2 id="7-6-Math-fround"><a href="#7-6-Math-fround" class="headerlink" title="7.6 Math.fround()"></a>7.6 Math.fround()</h2><p>方法返回一个数的32位单精度浮点数形式。</p>
<h2 id="7-7-Math-hypot"><a href="#7-7-Math-hypot" class="headerlink" title="7.7 Math.hypot()"></a>7.7 Math.hypot()</h2><p>方法返回所有参数的平方和的平方根。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">Math</span>.hypot(<span class="number">3</span>, <span class="number">4</span>);        <span class="comment">// 5</span></span><br><span class="line"><span class="built_in">Math</span>.hypot(<span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>);     <span class="comment">// 7.0710678118654755</span></span><br><span class="line"><span class="built_in">Math</span>.hypot();            <span class="comment">// 0</span></span><br><span class="line"><span class="built_in">Math</span>.hypot(<span class="literal">NaN</span>);         <span class="comment">// NaN</span></span><br><span class="line"><span class="built_in">Math</span>.hypot(<span class="number">3</span>, <span class="number">4</span>, <span class="string">&#x27;foo&#x27;</span>); <span class="comment">// NaN</span></span><br><span class="line"><span class="built_in">Math</span>.hypot(<span class="number">3</span>, <span class="number">4</span>, <span class="string">&#x27;5&#x27;</span>);   <span class="comment">// 7.0710678118654755</span></span><br><span class="line"><span class="built_in">Math</span>.hypot(-<span class="number">3</span>);          <span class="comment">// 3</span></span><br></pre></td></tr></table></figure>
<h2 id="7-8-对数方法"><a href="#7-8-对数方法" class="headerlink" title="7.8 对数方法"></a>7.8 对数方法</h2><p>ES6新增了4个对数相关方法。</p>
<h3 id="1-Math-expm1"><a href="#1-Math-expm1" class="headerlink" title="(1)Math.expm1()"></a>(1)Math.expm1()</h3><p>Math.expm1(x)返回e的x次方-1，即Math.exp(x)-1。</p>
<h3 id="2-Math-log1p"><a href="#2-Math-log1p" class="headerlink" title="(2)Math.log1p()"></a>(2)Math.log1p()</h3><p>方法返回1+x的自然对数，即Math.log(x+1)。如果x小于-1，返回NaN。</p>
<h3 id="3-Math-log10"><a href="#3-Math-log10" class="headerlink" title="(3)Math.log10()"></a>(3)Math.log10()</h3><p>返回以10为底的x的对数。如果x小于0，则返回NaN。</p>
<h3 id="4-Math-log2"><a href="#4-Math-log2" class="headerlink" title="(4)Math.log2()"></a>(4)Math.log2()</h3><p>返回以2为底的x的对数。如果x小于0，则返回NaN。</p>
<h2 id="7-9-双曲函数方法"><a href="#7-9-双曲函数方法" class="headerlink" title="7.9 双曲函数方法"></a>7.9 双曲函数方法</h2><p>ES6新增了6个双曲函数方法。<br>Math.sinh(x) 返回x的双曲正弦<br>Math.cosh(x) 返回x的双曲余弦<br>Math.tanh(x) 返回x的双曲正切<br>Math.asinh(x) 返回x的反双曲正弦<br>Math.acosh(x) 返回x的反双曲余弦<br>Math.atanh(x) 返回x的反双曲正切</p>
<h1 id="8-指数运算符"><a href="#8-指数运算符" class="headerlink" title="8.指数运算符"></a>8.指数运算符</h1><p>ES2016新增一个指数运算符（**）。<br>注意：这个运算符的一个特点是右结合，而不是常见的左结合。多个指数运算符连用时，是从最右边开始计算的。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 相当于 2 ** (3 ** 2)</span></span><br><span class="line"><span class="number">2</span> ** <span class="number">3</span> ** <span class="number">2</span></span><br><span class="line"><span class="comment">// 512</span></span><br></pre></td></tr></table></figure>
<h1 id="9-BigInt数据类型"><a href="#9-BigInt数据类型" class="headerlink" title="9. BigInt数据类型"></a>9. BigInt数据类型</h1><h2 id="9-1-简介"><a href="#9-1-简介" class="headerlink" title="9.1 简介"></a>9.1 简介</h2><p>JavaScript所有数字都保存成64位浮点数，这给数值的表示带来了两大限制。一是数值的精度只能到53个二进制位（相当于16个十进制位），大于这个范围的整数，</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:1767359165@qq.com">lihao</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://lh521.top/2021/03/09/es6-shu-zhi-de-kuo-zhan/">https://lh521.top/2021/03/09/es6-shu-zhi-de-kuo-zhan/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://lh521.top" target="_blank">LH</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/ES6/">ES6</a></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/03/12/FwCNIhKedQUOlrj.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="next-post pull-full"><a href="/2021/03/09/js-zhong-reduce-de-yong-fa/"><img class="next-cover" data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">js中reduce()的用法</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="/img/touxiang.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">lihao</div><div class="author-info__description">千磨万击还坚劲，任尔东西南北风</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">11</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">6</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/LHNB521"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/LHNB521" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1-%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%92%8C%E5%85%AB%E8%BF%9B%E5%88%B6%E7%9A%84%E8%A1%A8%E7%A4%BA%E6%96%B9%E6%B3%95"><span class="toc-text">1.二进制和八进制的表示方法</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-Number-isFinite-Number-isNaN"><span class="toc-text">2.Number.isFinite(),Number.isNaN()</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3-Number-parseInt-Number-parseFloat"><span class="toc-text">3.Number.parseInt(),Number.parseFloat()</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-Number-isInteger"><span class="toc-text">4.Number.isInteger()</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#7-Math%E5%AF%B9%E8%B1%A1%E7%9A%84%E6%89%A9%E5%B1%95"><span class="toc-text">7.Math对象的扩展</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#7-1-Math-trunc"><span class="toc-text">7.1 Math.trunc()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-2-Math-sign"><span class="toc-text">7.2 Math.sign()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-3-Math-cbrt"><span class="toc-text">7.3 Math.cbrt()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-4-Math-clz32"><span class="toc-text">7.4 Math.clz32()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-5-Math-imul"><span class="toc-text">7.5 Math.imul()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-6-Math-fround"><span class="toc-text">7.6 Math.fround()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-7-Math-hypot"><span class="toc-text">7.7 Math.hypot()</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-8-%E5%AF%B9%E6%95%B0%E6%96%B9%E6%B3%95"><span class="toc-text">7.8 对数方法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-Math-expm1"><span class="toc-text">(1)Math.expm1()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-Math-log1p"><span class="toc-text">(2)Math.log1p()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-Math-log10"><span class="toc-text">(3)Math.log10()</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-Math-log2"><span class="toc-text">(4)Math.log2()</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-9-%E5%8F%8C%E6%9B%B2%E5%87%BD%E6%95%B0%E6%96%B9%E6%B3%95"><span class="toc-text">7.9 双曲函数方法</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#8-%E6%8C%87%E6%95%B0%E8%BF%90%E7%AE%97%E7%AC%A6"><span class="toc-text">8.指数运算符</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#9-BigInt%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B"><span class="toc-text">9. BigInt数据类型</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#9-1-%E7%AE%80%E4%BB%8B"><span class="toc-text">9.1 简介</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/03/09/es6-shu-zhi-de-kuo-zhan/" title="ES6数值的扩展"><img data-lazy-src="https://i.loli.net/2021/03/12/FwCNIhKedQUOlrj.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6数值的扩展"/></a><div class="content"><a class="title" href="/2021/03/09/es6-shu-zhi-de-kuo-zhan/" title="ES6数值的扩展">ES6数值的扩展</a><time datetime="2021-03-09T02:44:54.000Z" title="发表于 2021-03-09 10:44:54">2021-03-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/09/js-zhong-reduce-de-yong-fa/" title="js中reduce()的用法"><img data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="js中reduce()的用法"/></a><div class="content"><a class="title" href="/2021/03/09/js-zhong-reduce-de-yong-fa/" title="js中reduce()的用法">js中reduce()的用法</a><time datetime="2021-03-09T02:00:00.000Z" title="发表于 2021-03-09 10:00:00">2021-03-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/20/html-ji-chu-zhi-shi/" title="HTML基础知识"><img data-lazy-src="https://i.loli.net/2021/03/12/ST85d6qtGrbC3pA.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="HTML基础知识"/></a><div class="content"><a class="title" href="/2021/01/20/html-ji-chu-zhi-shi/" title="HTML基础知识">HTML基础知识</a><time datetime="2021-01-20T07:44:15.000Z" title="发表于 2021-01-20 15:44:15">2021-01-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/14/es6-ji-chu-new-set/" title="ES6 基础new Set"><img data-lazy-src="https://i.loli.net/2021/03/12/xTebED5CWjHhamu.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6 基础new Set"/></a><div class="content"><a class="title" href="/2021/01/14/es6-ji-chu-new-set/" title="ES6 基础new Set">ES6 基础new Set</a><time datetime="2021-01-14T08:17:26.000Z" title="发表于 2021-01-14 16:17:26">2021-01-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/01/14/es6-zhi-array.from-fang-fa/" title="ES6之Array.frome()方法"><img data-lazy-src="https://i.loli.net/2021/03/12/cPIrwnNEviljtzR.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="ES6之Array.frome()方法"/></a><div class="content"><a class="title" href="/2021/01/14/es6-zhi-array.from-fang-fa/" title="ES6之Array.frome()方法">ES6之Array.frome()方法</a><time datetime="2021-01-14T06:36:01.000Z" title="发表于 2021-01-14 14:36:01">2021-01-14</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By lihao</div><div class="footer_custom_text">Hi, welcome to my blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (true){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><div class="js-pjax"><script async="async">var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> {preloader.endLoading()})
setTimeout(function(){preloader.endLoading();}, 3000);</script></div><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    let initData = {
      el: '#vcomment',
      appId: 'lDobFwQLFcnz4yK58fQosgWV-gzGzoHsz',
      appKey: 'UwqhtHozxle3aJU3a9emNAsa',
      placeholder: 'Please leave your footprints',
      avatar: 'monsterid',
      meta: 'nick,mail,link'.split(','),
      pageSize: '10',
      lang: 'en',
      recordIP: false,
      serverURLs: '',
      emojiCDN: '',
      emojiMaps: "",
      enableQQ: false,
      path: window.location.pathname,
    }

    if (true) { 
      initData.requiredFields= ('nick,mail'.split(','))
    }
    
    if (false) {
      const otherData = false
      initData = Object.assign(initData, otherData)
    }
    
    const valine = new Valine(initData)
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !false) {
  if (false) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"]):not([href="/bb/"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  if (typeof gtag === 'function') {
    gtag('config', '', {'page_path': window.location.pathname});
  }

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})


document.addEventListener('pjax:send', function () {
  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>